import instance from '../model/instance';
import model from '../model/model';
import action from '../model/action';
import tools from '../tools'
const clz={...instance,...model,...action}
export default {
    getClass:(name)=>{
        return clz[name];
    },
    create:(name,record)=>{
        let obj=clz[name].create(record);
        return tools.proxy(obj);
    },
    getTpl:(name)=>{
        let obj=clz[name].tpl();
        return obj;
    },
    observe(name,record,{get=null,set=null}){
        let obj=clz[name].create(record);
        return tools.proxyObject(obj,{get,set})
    },
    getModelType:(modelType)=>{
        let tmpTypeList = []
        switch (modelType) {
            case 'logic':
                tmpTypeList.push({label: 'logicDictionary', value: 'logicDictionary'})
                tmpTypeList.push({label: 'logicTree', value: 'logicTree'})
                tmpTypeList.push({label: 'logicQueue', value: 'logicQueue'})
                tmpTypeList.push({label: 'logicSingleton', value: 'logicSingleton'})
                break;
            case 'twins':
                tmpTypeList.push({label: 'twinsDictionary', value: 'twinsDictionary'})
                tmpTypeList.push({label: 'twinsTree', value: 'twinsTree'})
                tmpTypeList.push({label: 'twinsQueue', value: 'twinsQueue'})
                tmpTypeList.push({label: 'twinsSingleton', value: 'twinsSingleton'})
                break;
            case 'template':
                tmpTypeList.push({label: 'templateDictionary', value: 'templateDictionary'})
                tmpTypeList.push({label: 'templateTree', value: 'templateTree'})
                tmpTypeList.push({label: 'templateQueue', value: 'templateQueue'})
                tmpTypeList.push({label: 'templateSingleton', value: 'templateSingleton'})
                break;
            case 'routing':
                tmpTypeList.push({label: 'routing', value: 'routing'})
                break;
            case 'process':
                tmpTypeList.push({label: 'process', value: 'process'})
                break;
            case 'BI':
                tmpTypeList.push({label: 'BI', value: 'BI'})
                break;
            case 'statistics':
                tmpTypeList.push({label: 'statistics', value: 'statistics'})
                break;
            case 'statTemplate':
                tmpTypeList.push({label: 'statisticsTemplate', value: 'statisticsTemplate'})
                break;
            default :
                tmpTypeList.push({label: 'entity', value: 'entity'})
                break;
        }
        return tmpTypeList;
    },
    getHierTpl(){
        return {
            basic:{
                name:'',
                title:'title',
                model:'',
                pointer:{},
                values:{}
            },
            basicTree:{
                id:'',
                parentId:'',
                name:'',
                title:'',
                model:'',
                pointer:{},
                values:{}
            },
            twinsDictionary:{
                basic:[
                    {
                        name:'',
                        title:'title',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
                equipment:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ]
            },
            twinsQueue:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
                equipment:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ]
            },
            twinsTree:{
                basic:[
                    {
                        id:'',
                        parentId:'',
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
                equipment:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ]
            },
            twinsSingleton:{
                basic:{
                    name:'',
                    title:'',
                    model:'',
                    pointer:{},
                    values:{}
                },
                equipment:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ]
            },
            logicDictionary:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicQueue:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicTree:{
                basic:[
                    {
                        id:'',
                        parentId:'',
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicSingleton:{
                basic:{
                    name:'',
                    title:'',
                    model:'',
                    pointer:{},
                    values:{}
                },
            },
            templateDictionary:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            templateQueue:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            templateTree:{
                basic:[
                    {
                        id:'',
                        parentId:'',
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            templateSingleton:{
                basic:{
                    name:'',
                    title:'',
                    model:'',
                    pointer:{},
                    values:{}
                },
            },
        }
    },
    getModelList(locale='en-US'){
        return [
            // {label:{"en-US":'entity',"zh-CN":'实体'}[locale],value:'entity'},
            // {label:{"en-US":'twins',"zh-CN":'孪生'}[locale],value:'twins'},
            // {label:{"en-US":'logic',"zh-CN":'逻辑'}[locale],value:'logic'},
            // {label:{"en-US":'template',"zh-CN":'模板'}[locale],value:'template'},
            {label:{"en-US":'statistics',"zh-CN":'统计'}[locale],value:'statistics'},
        ]
    }
}
